<?php

namespace backend\component;


use common\component\ClassFactory;
use common\exceptions\ClassNotFoundException;
use yii\base\Action;
use yii\base\Exception;

class BaseAction extends Action
{
    /**
     * model name 如:common\models\Admin
     * @var
     */
    public $modelName;

    protected $modelObj = null;

    public $successMsg = "操作成功";


    public function init()
    {
        if (!empty($this->modelName)){
            try{
                $this->modelObj = ClassFactory::getInstance($this->modelName);
            }catch (Exception $e) {
                throw new Exception($e->getMessage());
            }
        } else {
            throw new ClassNotFoundException("未设置model类名,");
        }
    }
}